package com.boxing.dao;

import com.boxing.beans.Book;

import java.util.ArrayList;
import java.util.List;

public class BookDao extends BaseDao{

    public List<Book> searchBooks(int page, int count){
        int limit1 = count * (page -1);
        List<Book> books = queryList("select id,name,price,img from t_book limit ?,?", Book.class, limit1, count);
        return new ArrayList<>(books);
    }

    public long searchBooksCount(){
        return (long) queryValue("select count(1) from t_book");
    }

    public Book searchBookFromId(String id){
        return queryOne("select id,name,price,img from t_book where id=?", Book.class, id);
    }
}
